<%@ page language="java" %>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> 

<%@ page import="com.broadvision.portal.services.PortalVisitor" %>
<%@ page import="com.broadvision.ssp.client.SspInstance" %>
<%@ page import="com.broadvision.ssp.common.SSContext" %>
<%@ page import="com.broadvision.ssp.webflow.WebflowHelper" %>
<%@ page import="com.broadvision.visitor.client.Visitor" %>
<%@ page import="com.broadvision.visitor.interfaces.SimpleGroup" %>
<%@ page import="com.broadvision.portal.services.microsite.BizProcessMicrosite" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.List" %>

<%@ include file="/ga/common/layout/charset.jsp" %>

<% 
    SSContext ctx = WebflowHelper.getWebflowContext(request);
    String pickListGrp = request.getParameter("ReviewerGroup");
    SspInstance sspInst = WebflowHelper.getSSPInstance(request);
    BizProcessMicrosite site = sspInst.getMicrosite();
//    SimpleGroup actorGrp = site.getActorGroup("ReviewerGroup");
    SimpleGroup actorGrp = site.getActorGroup(pickListGrp);
    List visitors = actorGrp.getVisitors(true);

    int size = visitors.size();
    ArrayList userNameList = new ArrayList(size);
    ArrayList userAliasList = new ArrayList(size);

    for (int i=0; i < size; i++) {
	PortalVisitor portalVisitor = (PortalVisitor) visitors.get(i);
	Visitor visitor = portalVisitor.getVisitor();
	userNameList.add(visitor.getName());
	userAliasList.add(visitor.getStringValue("NAME"));
    }

// logic to pickup the right stylesheet
    String ctPath = request.getContextPath();
    String stylePath = "";    
    if( ctPath.equals("/bvmc") ) {
      stylePath = ctPath + "/mc/css/global.css";
    }
    else if(ctPath.equals("/portal") ) {
      stylePath = ctPath + "/ep/css/globalc3.css";
    }
    else {
      stylePath = ctPath + "/ga/css/globalc3.css";
    }
%>
	
<html:html locale="true">
<head>        
  <title><bean:message bundle="appCommonRes" key="dr.listUser.title"/></title>
  <link rel="stylesheet" type="text/css" href="<%= stylePath %>">
</head>

<body>

<script language="JavaScript">
function setResult() {
  window.opener.clearAdmin();

  size = document.form1.elements.length;
  counter = 0;
  for (var i=0; i<size; i++) {
    if (document.form1.elements[i].checked) {
      value = document.form1.elements[i].value;
      window.opener.setAdmin(value, value, counter);
      counter++;
    }
  }

  self.close();
}
</script>

<table class="zoneFive" cellspacing="0" cellpadding="0" width="100%" border="0" summary="content zone">
<tr>
<td valign="top" width="100%">
	  
<div class="generalWrapRight">
<input type="submit" class="inputButton" value="<bean:message bundle="appCommonRes" key="dr.closeWindow"/>" onClick="self.close()">
</div> 
	  
<div class="app_pageSubtitle">
<span class="left"><bean:message bundle="appCommonRes" key="dr.listUser.title"/></span>
<span class="right">&nbsp;</span>
</div>

<form name="form1" >

<div class="blockWrap">

<table class="dataTable" border="0" cellspacing="1" cellpadding="2" width="100%" summary="<bean:message bundle="appCommonRes" key="dr.reviewerList"/>">
<tr class="listHeader"> 
  <th id="Select" align="center"><bean:message bundle="appCommonRes" key="dr.select"/></th>
  <th id="User Alias" align="left"><bean:message bundle="appCommonRes" key="dr.userAlias"/></th>
  <th id="User Name" align="left" nowrap><bean:message bundle="appCommonRes" key="dr.userName"/></th>
</tr>     
<%
   for (int i=0; i<size; i++) {
	String userName = (String) userNameList.get(i);
	String userAlias = (String) userAliasList.get(i);
%>
<tr>
<td headers="Select" width="10%" align="center"><input type="checkbox" name="userAlias" value="<%=userName%>"></td>
<td headers="User Alias" width="40%"><%=userName%></td>
<td headers="User Name" width="50%"><%= userAlias%></td>
</tr>
<%
   }
%>
</table>

<div class="pageButtonWrap" align="right">
<input hspace="40" type="button" name="Submit" class="pageButton" value="<bean:message bundle="appCommonRes" key="dr.done"/>" onClick="setResult()">
</div>

</div>
</form>

</td>
</tr>
</table>

</body>
</html:html>
